#lang racket

(define id (lambda (x) x))

(define inc (lambda (x) (+ x 1)))

(define dec (lambda (x) (- x 1)))

(define sqr (lambda (x) (* x x)))

(define (compose f g)
  (lambda (x) (f (g x))))

(define (double f)
  (compose f f))

(define (nth f n)
  (cond ((<= n 0) id)
        ((= n 1) f)
        (else (compose f (nth f (- n 1))))))

(define (2^nth f n)
  (cond ((= n 0) f)
        (else (double (2^nth f (- n 1))))))

((2^nth inc 10) 0)

